//
//  LabelControlM.m
//  
//  jhf
//
//  Created by Mac on 2020/7/21.
//

#import "LabelControlM.h"
#import <CooperSDK/UIColor+BFPaperColors.h>
#import <CooperSDK/NSString+JCategory.h>
#import <CooperSDK/NSString+Size.h>

@implementation LabelControlM

+ (LabelControlM *)defaultText:(NSString *)text; {
    LabelControlM *model = [[LabelControlM alloc] init];
    /// 显示
    model.textStr = text;
    model.textStrFont = [UIFont systemFontOfSize:15];
    model.textTextAlignment = NSTextAlignmentLeft;
    model.textColorHex = @"#333333";
    model.lines = 1;
    return model;
}

- (void)controlLB:(UILabel *)lb; {
    [self controlV:lb];
    if (self.textAttributedText) {
        lb.attributedText = self.textAttributedText;
    }else if (self.textStr) {
        lb.text = self.textStr;
        lb.textColor = [UIColor colorWithHexString:self.textColorHex];
    }
    lb.numberOfLines = self.lines;
    lb.font = self.textStrFont;
    lb.textAlignment = self.textTextAlignment;
}

- (CGFloat)labelWidth {
    if (!(self.textStr && self.textStr.length > 0)) {
        return 0.0;
    }
    return [self.textStr widthWithFont:self.textStrFont constrainedToHeight:0];
}

@end
